import request from "../../../utils/request";
import { attrDataResponseForm, categoryResponseForm } from "./type";

enum API {
  getCategory1Url = "/admin/product/getCategory1",
  getCategory2Url = "/admin/product/getCategory2/",
  getCategory3Url = "/admin/product/getCategory3/",
  getAttrInfoUrl = "/admin/product/attrInfoList/",
  saveAttrInfoUrl = "/admin/product/saveAttrInfo",
  delAttrInfoUrl = "/admin/product/deleteAttr/",
}

export const reqCategory1 = () =>
  request.get<any, categoryResponseForm>(API.getCategory1Url);
export const reqCategory2 = (id: number) =>
  request.get<any, categoryResponseForm>(API.getCategory2Url + id);
export const reqCategory3 = (id: number) =>
  request.get<any, categoryResponseForm>(API.getCategory3Url + id);
export const reqAttrInfo = (id1: number, id2: number, id3: number) =>
  request.get<any, attrDataResponseForm>(
    API.getAttrInfoUrl + `${id1}/${id2}/${id3}`
  );
export const reqSaveAttrInfo = (data: any) =>
  request.post<any, any>(API.saveAttrInfoUrl, data);
export const reqDelAttrInfo = (id: number) =>
  request.delete<any, any>(API.delAttrInfoUrl + id);
